import uvicorn
import sys

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles

from configs import config

if __name__ == "__main__":

    app = FastAPI(max_body_size=1024 * 1024 * 1024)
    app.add_middleware(
        CORSMiddleware,
        allow_origins=["*"],
        allow_methods=["*"],
        allow_headers=["*"],
        allow_credentials=True,
    )

    app.mount("/statics", StaticFiles(directory="statics"), name="statics")

    from modules import arixv_service
    app.include_router(arixv_service.router)

    from modules import video_service
    app.include_router(video_service.router)

    from modules import funasr_service
    app.include_router(funasr_service.router)

    from modules import knowledge_base_service
    app.include_router(knowledge_base_service.router)

    from proxies import InternlmProxy
    app.include_router(InternlmProxy.router)

    from proxies import ModelScopeProxy
    app.include_router(ModelScopeProxy.router)

    sys.path.append("thirdparty/HivisionIDPhotos")
    from modules import hivision_service
    app.include_router(hivision_service.router)

    sys.path.append("thirdparty/PDFMathTranslate")
    from modules import pdf_translate_service
    app.include_router(pdf_translate_service.router)

    # uvicorn.run(app, host=config.server.host, port=config.server.port, workers=1, ssl_keyfile=config.server.ssl_keyfile, ssl_certfile=config.server.ssl_certfile)
    uvicorn.run(app, host=config.server.host, port=config.server.port, workers=1)
